package bootstrap

import (
	"tdy-backend/app/ws/controller/v1"
	"tdy-backend/docs"
	"tdy-backend/middleware"
	"tdy-backend/router"

	"github.com/gin-gonic/gin"
	swaggerfiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func InitRouter() *gin.Engine {
	r := gin.Default()
	docs.SwaggerInfo.BasePath = "/Api/V1"
	routerInstance := new(router.RouterGroup)
	r.Use(middleware.JwtAuth()).Use(middleware.Cors())
	ws := v1.WsController{}
	wsGroup := r.Group("/ws")
	{
		wsGroup.GET("/:group", ws.Run)
	}
	group := r.Group("Api")
	{
		routerInstance.Member.ApiMemberRouter.MemberRouter(group)
		routerInstance.Member.ApiUploaderRouter.UploaderRouter(group)
		routerInstance.Panoramic.ApiMaterialRouter.MaterialRouter(group)
		routerInstance.Panoramic.ApiWorksRouter.WorksRouter(group)
		routerInstance.Panoramic.ApiGroupRouter.GroupRouter(group)
		routerInstance.Panoramic.ApiSceneRouter.SceneRouter(group)
	}
	r.Static("/runtime/upload", "./runtime/upload")
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
	return r

}
